package adfc2.actions;

import adfc2.core.Creature;
import adfc2.core.Item;
import adfc2.entities.DroppedItem;

/**
 * Created by IntelliJ IDEA.
 * User: aimozg
 * Date: 28.01.12
 * Time: 23:22
 */
public class PickupAction extends InstantAction {

    public final DroppedItem target;

    public PickupAction(Creature actor, DroppedItem target) {
        super(actor);
        this.target = target;
    }

    @Override
    protected boolean perform() {
        assert (actor.getXY() == target.getXY());
        Item item = target.item;
        target.remove();
        actor.addItem(item);
        return true;
    }

    @Override
    public String toString() {
        return "PickupAction[" + target + "]";
    }
}
